<template>
    <van-dialog v-model="dialogVisible" title="人工组卷列表" confirmButtonText='关闭' >
        <div
            style="
                padding: 0.75rem;
                background: #eee;
                max-height: 70vh;
                overflow: auto;
            "
            v-if="tableData.length != 0"
            >
            <div class="li" v-for="item in tableData" :key="item.id" @click="openExam(item)">
                <div class="li_item">
                {{ item.title }}
                </div>
                <div class="li_content">
                <div style="display: flex">
                        <span>合格标准:</span>
                    {{ inint.分值标准.及格 }}分及格(满分{{
                            Number(inint.试题分布.单选.总分) +
                            Number(inint.试题分布.多选.总分) +
                            Number(inint.试题分布.判断.总分)
                        }}分)
                </div>
                <div>
                    <span>考试标准:{{ inint.考试时长.时长 }}分钟，{{
                        Number(inint.试题分布.单选.数量) +
                        Number(inint.试题分布.多选.数量) +
                        Number(inint.试题分布.判断.数量)
                    }}题</span>
                </div>
                </div>
            </div>
        </div>
    <van-empty description="暂无人工组卷试题" v-else />
    </van-dialog>
</template>

<script>
import {paperlist,zujuanstart,zujuanstartexam} from '@/api/admin.js'
import { getsubject_id, getsubjectTitle, getapplyid } from "@/utils/auth";
export default {
    data() {
        return {
            dialogVisible:false,
            tableData:[],//试卷数据
            inint:{},
            applyid:'',
            daan:'',
        }
    },
    methods: {
        //打开模态框
        async open(data){
            const {applyid,name,obj,daan} = data
            this.dialogVisible=true
            this.inint=obj
            this.daan=daan
            this.applyid=applyid
            await paperlist({applyid:applyid,cate:name}).then(res=>{
                if(res.code==200){
                    this.tableData=res.data
                }
            })
        },
        handleClose(){
            this.dialogVisible=false
        },
        //打开考试页面
        openExam(data){
            if(data.cate=='模拟考试试卷'){
                zujuanstart({paperid:data.id,applyid:this.applyid}).then(res=>{
                if (res.code == 200) {
                    this.$store.commit("SET_TI", res.data.list);
                    this.$router.push(
                        "/exam?mockid=" +
                        res.data.mockid +
                        "&gz=" +
                        data.gz +
                        "&daan=" +
                        this.daan +
                        "&subjectid=" +
                        getsubject_id()
                        +"&rengong=1"+
                        "&titleName=模拟考试"
                    );
                }
            })
            }else{
                zujuanstartexam({paperid:data.id,applyid:this.applyid}).then(res=>{
                    if (res.code == 200) {
                        this.$store.commit("SET_TI", res.data.list);
                        this.$router.push(
                            "/exam?examid=" +
                            res.data.examid +
                            "&gz=" +
                            data.gz +
                            "&daan=" +
                            this.daan +
                            "&subjectid=" +
                            getsubject_id()
                            +"&rengong=1"+
                             "&titleName=正式考试"
                        );
                    }
                })
            }
        }
    },
}
</script>

<style lang="scss" scoped>
.li {
  padding: 0.75rem;
  background: #fff;
  font-size: 1rem;
  border-radius: 0.4rem;
  margin-top: 0.75rem;
  &:first-child {
    margin-top: 0;
  }
  .li_item {
    display: flex;
    justify-content: space-between;
    p {
      margin: 0;
      flex: 3;
    }
    span {
      flex: 2;
      font-weight: 600;
    }
  }
  .li_content {
    line-height: 2rem;
    margin-top: 0.75rem;
    span {
      font-weight: 600;
    }
    i {
      font-size: 1rem;
    }
  }
}
</style>